let tbody = document.querySelector('#list-tbody'); //获取元素
getDate()

function getDate() {
    utils.fetch('./api/v1/shop/select.php').then(resp => { //调用fetch方法 抓捕数据库数据
        // console.log(resp);
        if (resp.code === 200) { //判断code值
            let { list } = resp.body; //list表示数据库里面的所有数据 对象

            let html = list.reduce((str, shop, index) => {
                // console.log(index);
                //shop.id 等于数据库id 渲染页面
                str += `<tr data-id="${shop.Id}"> 
                <td>${index + 1}</td>
                <td><span>${shop.name}</span><input type="text" class=a></td>
                <td><span>${shop.price}</span><input type="text" class=a></td>
                <td><span>${shop.num}</span><input type="text" class=a></td>
                <td>
                    <button class="btn btn-info btn btn-primary btn-xs btn-edit">编辑</button>
                    <button class="btn btn-danger btn btn-primary btn-xs btn-del">删除</button>
                    <button class="btn btn-success btn btn-primary btn-xs btn-ok">确定</button>
                    <button class="btn btn-warning btn btn-primary btn-xs btn-cancel">取消</button>
                </td>
            </tr>`
                return str
            }, '')
            tbody.innerHTML = html
        } else {
            alert('网络错误，请重试')
        }
    })


}